package com.evil.application.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.evil.application.pojo.entity.ApplicationJudge;
import com.evil.common.application.dto.judge.*;
import com.evil.common.application.enums.judge.JudgeSourceTypeEnum;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 应用判断条件表
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
public interface ApplicationJudgeService extends IService<ApplicationJudge> {

    /**
     * 保存
     *
     * @param judgesDTO judgeSourceDTO
     */
    void saveJudges(JudgesDTO judgesDTO);

    /**
     * 复制
     *
     * @param copyJudgeReqDTO copyJudgeReqDTO
     */
    void copyJudges(CopyJudgeReqDTO copyJudgeReqDTO);

    /**
     * 获取条件列表
     *
     * @param source source
     * @return JudgeOr 列表
     */
    List<JudgeOr> findDTOBySource(JudgeSourceDTO source);

    /**
     * 获取条件列表
     *
     * @param sources sources
     * @return JudgeOr 列表
     */
    Map<JudgeSourceDTO, List<JudgeOr>> findDTOMapBySources(Collection<JudgeSourceDTO> sources);

    /**
     * 获取条件列表
     *
     * @param sourceTypeEnum sourceTypeEnum
     * @param sourceIds      sourceIds
     * @return Map
     */
    Map<Long, List<JudgeOr>> findMapBySourceIds(JudgeSourceTypeEnum sourceTypeEnum, List<Long> sourceIds);

    /**
     * 转换条件列表
     *
     * @param judges judges
     * @return JudgeOr
     */
    List<JudgeOr> judgeOrs(Collection<? extends Judge> judges);

    /**
     * 转DTO
     *
     * @param judges judges
     * @return Judge 列表
     */
    List<? extends Judge> toDto(Collection<ApplicationJudge> judges);

    /**
     * 检查 条件判断
     *
     * @param judgeOr        judgeOr
     * @param controlCodeMap controlCodeMap
     * @param controlIdMap   controlIdMap
     */
    void checkJudge(List<JudgeOr> judgeOr, Map<Long, String> controlCodeMap, Map<Long, Long> controlIdMap);

}
